import { Prop, raw, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

const data = raw({
  timestamp : {type : Number},
  updateTime : {type : Number},
  consumeTime : {type : Number},
  power : {type : Number},
  voltage : {type : Number},
  current : {type : Number},
  consumeEnergy : {type : Number},
  temperature : {type : Number}
})

export type ChargeOrderRealTimeInfocument = ChargeOrderRealTimeInfo & Document;

@Schema({
  collection : 'charge_order_real_time_info'
})
export class ChargeOrderRealTimeInfo extends Document {
  @Prop()
  orderId: number;

  @Prop(data)
  lastData: Record<string, any>;

  @Prop([data])
  data: Record<string, any>[];
}

export const ChargeOrderRealTimeInfoSchema = SchemaFactory.createForClass(ChargeOrderRealTimeInfo);